<?php
include "../model/db.php";

function createTable()
{
   $stmt = Database::getConnection()->prepare("CREATE TABLE IF NOT EXISTS 
    `guestbookshared` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `name` varchar(50) NOT NULL,
    `date` datetime DEFAULT NULL,
    `entry` text NOT NULL,
     KEY `id` (`id`)
     ) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=latin1 COMMENT='shared'");
   return $stmt->execute();
}

function alterTable()
{
    $stmt = Database::getConnection()->prepare("RENAME TABLE
    `guestbookshared4` TO `guestbookshared1337`");
    return $stmt->execute();
}

function dropTable()
{
    $stmt = Database::getConnection()->prepare("DROP TABLE IF EXISTS
    `guestbookshared1337`");
    return $stmt->execute();
}

$createTable = createTable();

//checks if $createTable is true or false
//if ($createTable) IS THE SAME
if ($createTable == true) {
    echo 'Table created';
} else {
    echo 'Table NOT created';
}

//$alterTable = alterTable();
//var_dump($alterTable);

//$dropTable = dropTable();
//var_dump($dropTable);